package com.atguigu;


import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/servletA")
public class servletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("servletA收到请求");
        //转发到servlet
        //RequestDispatcher servletB = req.getRequestDispatcher("servletB");
        //转发到视图
        //RequestDispatcher servletB = req.getRequestDispatcher("1.html");
        //转发到WEB-INF下的资源(唯一访问WEB-INF下资源的方式)
        RequestDispatcher servletB = req.getRequestDispatcher("WEB-INF/2.html");
        //不能转发到url
        servletB.forward(req,resp);
    }
}
